// api/login.js
import service from '@/utils/request.js'; // 引入封装的 axios 实例

const userApi = {
  login: '/user/loginByPassword', // 登录接口
  getUserInfo:'/user/getMyUserInfo' ,// 获取用户信息：昵称、头像
  editUserInfo: '/user/editPrivateMessage' ,//编辑用户个人信息
  getOtherUserInfo:'/user/getOtherUserInfo',
  getOtherPost:'/user/getOtherPost',
  register: '/user/register',
  getMyPost: '/user/getMyPost',
  followList: '/follow/followList',  // 添加关注列表接口路径
  fansList: '/follow/fansList' ,      // 添加粉丝列表接口路径
  follow: '/follow'
};

// 用户登录
export const userLogin = (data) => {
  return service.post(userApi.login, data);
};

export const getUserInfo = () => {
  return service.get(userApi.getUserInfo);
};

export const editUserInfo = (data) => {
  return service.post(userApi.editUserInfo, data);
};

export const userRegister = (data) => {
  return service.post(userApi.register, data);
};

// 获取用户发布的帖子列表
export const getMyPost = (pageNum, pageSize,type) => {
  return service.get(userApi.getMyPost, {
    params: { pageNum, pageSize, type}
  });
};

// 获取关注列表
export const getFollowList = (pageNo, pageSize) => {
  return service.get(userApi.followList,{
    params: { pageNo, pageSize }
  });
};

// 获取粉丝列表
export const getFansList = (pageNo, pageSize) => {
  return service.get(userApi.fansList,{
    params: { pageNo, pageSize }
  });
};

export const postFollow = (data) => {
  return service.post(userApi.follow, data);
};

//获取别人用户信息
export const getOtherUserInfo = (userId) => {
  return service.get(userApi.getOtherUserInfo,{
    params: { userId}
  });
};

export const getOtherPost = (userId ,pageNo, pageSize) => {
  return service.get(userApi.getOtherPost,{
    params: { userId,pageNo,pageSize }
  });
};